﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Omes.Services;

namespace FashionMural.Web
{
    public partial class Index : System.Web.UI.Page
    {
        public int PageImageIndex = 0;
        private IPageService pageservice;
        private IResourceService resourceservice;
        public List<Omes.Model.Page> ServerPages;
        public List<Omes.Model.Page> ProductPages;
        public List<Omes.Model.NewsList> NewsLinks;
        public Dictionary<int, List<Omes.Model.ImageList>> ImageDic;
        protected void Page_Load(object sender, EventArgs e)
        {
            pageservice = new PageService();
            resourceservice = new ResourceService();
            ImageDic = new Dictionary<int, List<Omes.Model.ImageList>>();
            //获取服务项目子页面
            int sid = int.Parse(System.Configuration.ConfigurationManager.AppSettings["fwxm"]);
            ServerPages = pageservice.GetChildPage(sid);
            //获取新闻列表
            int nid = int.Parse(System.Configuration.ConfigurationManager.AppSettings["xwzx"]);
            NewsLinks = resourceservice.GetNews(nid, commend: 1).Lists;
            //获取产品中心子页面
            int pid = int.Parse(System.Configuration.ConfigurationManager.AppSettings["cpzx"]);
            ProductPages = pageservice.GetChildPage(pid).Where(i => i.PageTypeId == 2).ToList();
            //获取产品子页面资源
            foreach (var p in ProductPages)
            {
                var res = resourceservice.GetImages(p.Id, commend: 1);
                ImageDic.Add(p.Id, res.Images.Take(10).ToList());
            }

        }
    }
}